package migrations

import (
	"github.com/goravel/framework/contracts/database/schema"
	"github.com/goravel/framework/facades"
)

type M20250701093144CreateSysRolesTable struct {
}

// Signature The unique signature for the migration.
func (r *M20250701093144CreateSysRolesTable) Signature() string {
	return "20250701093144_create_sys_roles_table"
}

// Up Run the migrations.
func (r *M20250701093144CreateSysRolesTable) Up() error {
	if !facades.Schema().HasTable("sys_role") {
		return facades.Schema().Create("sys_role", func(table schema.Blueprint) {
			table.ID()
			table.String("name").Comment("名称")
			table.String("slug").Comment("标识")
			table.String("remark").Nullable().Comment("描述")
			table.Integer("sort").Default(0).Comment("排序")
			table.Integer("status").Default(0).Comment("状态")
			table.TimestampsTz()

			table.Unique("slug")
		})
	}

	return nil
}

// Down Reverse the migrations.
func (r *M20250701093144CreateSysRolesTable) Down() error {
	return facades.Schema().DropIfExists("sys_role")
}
